#!/bin/sh

##############################################
# Configuration                              #
##############################################
# path variables
basePath=C:/PAPYRUS
eclipsePath=$basePath/Eclipse/Eclipse3.3.1.1/eclipse
toolsdir="C:/Program Files"/
equinoxLauncher=org.eclipse.equinox.launcher_1.0.1.R33x_v20070828.jar
pdeScriptBuilder=org.eclipse.pde.build_3.3.2.R331_v20071019

# build identification
buildType=N
buildId=`date +%Y%m%d` # buildId(date format : YYYYmmDD)
echo "buildID: "$buildId
buildLabel=Papyrus_$buildId
echo $buildLabel
version=1.9.1

# build directory
buildDirectory=$basePath/Build/RCP_RELEASE_1.9.1
binariesDir=$basePath/Resources/Binaries
relengDir=$buildDirectory/com.cea.papyrus.releng
productScriptsDir=$relengDir/scripts/product
updateSiteScriptsDir=$relengDir/scripts/updateSite
resultDir=$buildDirectory/result

installerResourceDir=$buildDirectory/$buildLabel/Papyrus-$version

# map file dir
mapsRoot=$relengDir/maps/

# Repository version : head, release or branch for product plugin (here, org.usinelogicielle.platform) and for maps project!!
# possibilities : head or releases/1.4.5 or branch/1.7.X
tagPath=releases/1.9.1

###############################################################################
# METHODS
###############################################################################

############################################
# Clean Build Space
# clean files comming from previous builds
############################################
# clean files from previous build
rm -vf $buildDirectory/*.properties
rm -vf $buildDirectory/*.xml
rm -vf $buildDirectory/directory.txt

# checkout maps file (not useful, maps are integrated in the releng project for Papyrus
echo Checkout map files 
rm -rvf $buildDirectory/maps
mkdir $buildDirectory/maps
cp --force $mapsRoot/*.map $buildDirectory/maps/ 

# launch building application
java -jar $eclipsePath/plugins/$equinoxLauncher -application org.eclipse.ant.core.antRunner -buildfile $eclipsePath/plugins/$pdeScriptBuilder/scripts/build.xml -Dbuilder=$updateSiteScriptsDir -DbuildId=$buildId -DbuildLabel=$buildLabel -DbuildDirectory=$buildDirectory -Dversion=$version -DpluginPath=$binariesDir -DmapsRoot=$mapsRoot

# copy site.xml skeleton while replacing @@@papyrusVersion@@@ with papyrus version number 
sed -e "s/@@@papyrusVersion@@@/$version/g" $relengDir/updateSite/site.xml > $buildDirectory/$buildLabel/site.xml

# update site archive
cd $buildDirectory/$buildLabel/
WINZIP32 -min -a com.cea.papyrus.feature-$buildId.zip site.xml
 

	

